package com.atguigu.bigdata.scala.mytest.chapter06;

/**
 * 初始化子类必须先初始化父类
 * 	继承关系下 所有类的构造器第一行默认存在  super();调用父类的无参构造
 * 	Java提供一个无参数构造器,若自己创建了构造器,java自动提供的构造器就会失效
 */
public class Test7 {
    public static void main(String[] args) {
        Student student = new Student(10,"fsd");
        student.a();
    }
}

class Person {
    int age;

    public Person() {
        System.out.println("person 无参");
    }

    public Person(int age) {
        this.age = age;
        System.out.println("person 有参");
    }

    public void a(){
        System.out.println("aaaa");
    }
}

class Student extends Person{
    String name;

    public Student() {
        System.out.println("Student 无参");
    }

    public Student(String name) {
        System.out.println("Student 有参");
        this.name = name;
    }

    public Student(int age, String name) {
        super(age);
        this.name = name;
        System.out.println("Student 有参2");
    }
}

